export const schema = {
    type: "page",
    title: "星级志愿者列表",
    body: {
        type: "crud",
        api: "get:/api/volunteer",
        columnsTogglable: false,
        showHeader: true,
        bulkActions: [
            {
                label: "通过认定",
                type: "button",
                level: "success",
                actionType: "ajax",
                api: "post:/api/volunteer/star_certificate/accept/${ids}"
            },

            {
                label: "拒绝认定",
                type: "button",
                level: "danger",
                actionType: "ajax",
                api: "post:/api/volunteer/star_certificate/reject/${ids}"
                // actionType: "dialog",
                // dialog: {
                //     title: "批量不通过",
                //     body: {
                //         type: "form",
                //         api: "post:/api",
                //         controls: [
                //             {
                //                 type: "text",
                //                 label: "驳回理由",
                //                 name: "reason"
                //             }
                //         ]
                //     }
                // }
            },

            {
                label: "通知",
                type: "button",
                level: "primary",
                actionType: "dialog",
                dialog: {
                    title: "批量群发消息",
                    body: {
                        type: "form",
                        api: "post:/api/volunteer/notify/${ids}",
                        controls: [
                            {
                                type: "textarea",
                                label: false,
                                name: "content"
                            }
                        ]
                    }
                }
            }
        ],
        filter: {
            title: "",
            submitText: "",
            panelClassName: 'no-border no-shadow b-b m-b-none b-light',
            controls: [
                {
                    type: "button-group",
                    btnActiveClassName: "btn-info active",
                    value: "",
                    submitOnChange: true,
                    name: "stars_verify_status",
                    options: [
                        {
                            label: "全部",
                            value: ""
                        },
                        {
                            label: "待认定",
                            value: "0"
                        },
                        {
                            label: "已认定",
                            value: "1"
                        },
                        // {
                        //     label: "未通过审核",
                        //     value: "2"
                        // }
                    ]
                },
                {
                    // label: "达标星级",
                    type: "select",
                    name: "stars_verify_num",
                    placeholder: "请选择达标星级",
                    options: [
                        {
                            label: "1星",
                            value: "1"
                        },
                        {
                            label: "2星",
                            value: "2"
                        },
                        {
                            label: "3星",
                            value: "3"
                        },
                        {
                            label: "4星",
                            value: "4"
                        },
                        {
                            label: "5星",
                            value: "5"
                        },
                        {
                            label: "全部",
                            value: '',
                        },
                    ]
                },
                {
                    type: "text",
                    name: "keyword",
                    placeholder: "用户名/姓名/证件号",
                    style: {minWidth: 260},
                    addOn: {
                        type: "submit",
                        label: "搜索",
                        primary: true
                    }
                },

            ]
        },
        columns: [
            {
                name: "identifier",
                label: "志愿者编号"
            },

            {
                name: "stars",
                label: "当前星级"
            },

            {
                name: "stars_verify_num",
                label: "达标星级",
            },

            {
                name: "real_name",
                label: "姓名",
            },
            {
                name: "username",
                label: "用户名",
            },
            {
                label: "性别",
                name: 'sex',
                type: 'map',
                map: {
                    '1': '男',
                    '2': '女'
                }
            },
            {
                name: "age",
                label: "年龄",
            },
            {
                name: "nation",
                label: "民族",
            },
            {
                name: "score",
                label: "积分",
            },

            {
                label: "居住区域",
                innerClassName: 'w',
                type: "tpl",
                tpl: "${province_name} ${city_name} ${county_name} ${addr}"
            },
            {
                name: "icon",
                label: "所属团队",
            },
            {
                label: "参与项目数",
                name: 'project_count'
            },
            {
                label: "志愿时长",
                name: 'reward_time'
            },

            {
                label: "注册时间",
                name: "created_at",
                type: 'tpl',
                tpl: "${created_at|date:LL:YYYY-MM-DD HH:mm:ss}"
            },
            {
                name: "stars_verify_status",
                label: "认定状态",
                type: "map",
                map: {
                    '0': "<span class='label label-primary'>待认定</span>",
                    '1': "<span class='label label-success'>认证通过</span>",
                    '2': "<span class='label label-default'>拒绝认证</span>",
                }
            },

            {
                label: "操作",
                type: "operation",
                // width: 180,
                buttons: [
                    {
                        type: "button",
                        size: "xs",
                        level: "info",
                        label: "设置",
                        actionType: "dialog",
                        dialog: {
                            title: "设置认证星级",
                            body: {
                                type: "form",
                                api: "put:/api/volunteer/${id}",
                                controls: [
                                    {
                                        type: 'tpl',
                                        className: 'star-text',
                                        tpl: `
                    <p>
                    已有志愿时长<%= data.reward_time%>小时， 建议星级评定为： <%= data.stars_verify_num%>星
                    </p>
                    `
                                    },
                                    {
                                        type: 'star-rate',
                                        name: 'stars',
                                        required: true,
                                        label: '星级'

                                    }
                                ],
                            }
                        }
                    }
                ]
            }
        ]
    }
};
